<?php /* Smarty version 2.6.13, created on 2009-02-19 15:44:20
         compiled from user_edit.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', 'user_edit.tpl', 9, false),array('function', 'html_options', 'user_edit.tpl', 11, false),)), $this); ?>
<FORM method="post" action="/backend/users/save/">
<div class="form">
    <H1><?php if ($this->_tpl_vars['User']->isNew()): ?>Добавление пользователя<?php else: ?>Редактирование пользователя '<?php echo $this->_tpl_vars['User']->login; ?>
'<?php endif; ?></H1>
    <div class="operation"><a href="<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
users/" onclick="go('<?php echo $this->_tpl_vars['fvConfig']->get('dir_web_root'); ?>
users/'); return false;" class="left">вернутся к списку</a><div style="clear: both;"></div></div>
<div style="width: 50%; float: left;">

    <fieldset>
        <legend>Общая информация</legend>
        <label for="login">Логин</label> <input type="text" id="login" name="m[login]" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['User']->login)) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" <?php if (! $this->_tpl_vars['User']->isNew()): ?>readonly="readonly"<?php endif; ?>/> <br />
        <label for="group_id">Группа</label> 
        <?php echo smarty_function_html_options(array('name' => "m[group_id]",'id' => 'group_id','options' => $this->_tpl_vars['GroupManager']->htmlSelect('group_name'),'selected' => $this->_tpl_vars['User']->group_id), $this);?>
<br />
        <label for="email">Адрес электронной почты</label> <input type="text" id="email" name="m[email]" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['User']->email)) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
" /> <br />
        <label for="full_name">Полное имя</label> <input type="text" id="full_name" name="m[full_name]" value="<?php echo $this->_tpl_vars['User']->full_name; ?>
" /> <br />
        <label for="info">Описание</label> <textarea rows="3" id="info" name="m[info]"><?php echo $this->_tpl_vars['User']->info; ?>
</textarea> <br />
    </fieldset>

    <fieldset>
        <legend>Пароль пользователя</legend>
        <?php if (! $this->_tpl_vars['User']->isNew()): ?><p style="color: #922;">Оставте пароль пустым, если не хотите его изменять</p><?php endif; ?>
        <label for="password">Пароль</label> <input type="password" id="password" name="m[password]" /> <br />
        <label for="password1">Повторите пароль</label> <input type="password" id="password1" name="m[password1]" /> <br />
    </fieldset>
    
    <fieldset>
        <legend>Параметры пользователя</legend>
        <input type="checkbox" name="m[is_root]" value="1" id="m_is_root" <?php if ($this->_tpl_vars['User']->is_root): ?>checked="true"<?php endif; ?>>
        <label for="m_is_root" class="checkbox">суперпользователь</label> <br />
        <input type="checkbox" name="m[active]" value="1" id="m_active" <?php if ($this->_tpl_vars['User']->active): ?>checked="true"<?php endif; ?>>
        <label for="m_active" class="checkbox">активный пользователь</label> <br />
        <input type="checkbox" name="m[inherit]" value="1" id="m_inherit" <?php if ($this->_tpl_vars['User']->inherit): ?>checked="true"<?php endif; ?>>
        <label for="m_inherit" class="checkbox">наследовать параметры из группы</label> <br />
    </fieldset>

    <div class="buttonpanel">
        <input type="submit" name="save" value="Сохранить" class="button"  onclick="$('redirect').value = '';">
        <input type="submit" name="save_and_return" value="Сохранить и выйти" class="button" onclick="$('redirect').value = '1';">
    </div>
    <input type="hidden" name="id" id="id" value="<?php echo $this->_tpl_vars['User']->getPk(); ?>
" />
    <input type="hidden" id="redirect" name="redirect" value="" />
</div>
<div style="float: left; width: 40%; margin-left: 10px;">
<div id="user_params" <?php if ($this->_tpl_vars['User']->is_root): ?>style="display: none"<?php endif; ?>>

    <fieldset>
        <legend>Права доступа</legend>
        <div style="<?php if (! $this->_tpl_vars['User']->is_root): ?>display: none;<?php endif; ?>" id="parameters_list">
    <ul class="acls">
<?php $_from = $this->_tpl_vars['fvConfig']->get('acls'); if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['acl_name'] => $this->_tpl_vars['acl']):
?>

    <?php if (is_array ( $this->_tpl_vars['acl'] )): ?> 
        <li> 
        <input type="checkbox" name="" value="" id="m_permitions_<?php echo $this->_tpl_vars['acl_name']; ?>
" <?php echo 'onclick="$$(\'#content div.form ul.acls li input#m_permitions_';  echo $this->_tpl_vars['acl_name'];  echo ' + label + ul > li > input\').each(function (el) {el.checked = $(\'m_permitions_';  echo $this->_tpl_vars['acl_name'];  echo '\').checked}); $(\'m_inherit\').checked = false;"'; ?>
>
        <label for="m_permitions_<?php echo $this->_tpl_vars['acl_name']; ?>
" class="checkbox"><?php echo $this->_tpl_vars['acl']['name']; ?>
</label>
        <ul class="acls">
        <?php $_from = $this->_tpl_vars['acl']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['acl_chld_name'] => $this->_tpl_vars['acl_chld']):
?>
            <?php if ($this->_tpl_vars['acl_chld_name'] != 'name'): ?>
                <li><input type="checkbox" name="m[permitions][]" value="<?php echo $this->_tpl_vars['acl_chld_name']; ?>
" id="m_permitions_<?php echo $this->_tpl_vars['acl_chld_name']; ?>
" <?php if (in_array ( $this->_tpl_vars['acl_chld_name'] , $this->_tpl_vars['User']->permitions )): ?>checked="true"<?php endif; ?> onchange="$('m_inherit').checked = false; $('m_permitions_<?php echo $this->_tpl_vars['acl_name']; ?>
').checked = false;">
                <label for="m_permitions_<?php echo $this->_tpl_vars['acl_chld_name']; ?>
" class="checkbox"><?php echo $this->_tpl_vars['acl_chld']; ?>
</label></li>
            <?php endif; ?>
        <?php endforeach; endif; unset($_from); ?>
        </ul>
        </li>
    <?php else: ?>
        <li><input type="checkbox" name="m[permitions][]" value="<?php echo $this->_tpl_vars['acl_name']; ?>
" id="m_permitions_<?php echo $this->_tpl_vars['acl_name']; ?>
" <?php if (in_array ( $this->_tpl_vars['acl_name'] , $this->_tpl_vars['User']->permitions )): ?>checked="true"<?php endif; ?> onchange="$('m_inherit').checked = false;">
        <label for="m_permitions_<?php echo $this->_tpl_vars['acl_name']; ?>
" class="checkbox"><?php echo $this->_tpl_vars['acl']; ?>
</label></li>
    <?php endif;  endforeach; endif; unset($_from); ?>
</ul>
</div>
    </fieldset>
</div>
</div>
<div style="clear: both;" />
</div>
</FORM>
<?php echo '
<script>
    
    function changeInherit(e) {
        if ($(\'m_inherit\') && $(\'m_inherit\').checked && $(\'m_global_rights\').checked) {
            window.blockScreen();
            
            new Ajax.Request("';  echo $this->_tpl_vars['fvConfig']->get('dir_web_root');  echo 'usergroups/getparams", {
                parameters: {\'group_id\': $F(\'group_id\')},
                onComplete: function (response, json) {
                    if ($(\'contentblocker\')) $(\'contentblocker\').hide();
                    $$("div#parameters_list input").each(function (checkbox){
                        checkbox.checked = false;
                    });
                    $A(json).each(function (acl) {
                        alert(acl)
                        if ($(\'m_permitions_\'+acl)) {
                            $(\'m_permitions_\'+acl).checked = true;
                        }
                    });
                }
            });
        }
    }
    
    $(\'m_is_root\').observe(\'change\', function (e) {
        if (Event.element(e) && Event.element(e).checked) {
            $(\'user_params\').hide();
        } else {
            $(\'user_params\').show();
        }
    });
    
    $("m_inherit").observe(\'change\', changeInherit);
    $(\'group_id\').observe(\'change\', changeInherit);
    $(\'m_global_rights\').observe(\'change\', function (e) {
        elem = Event.element(e);
    
        if (elem.checked) {
            $(\'parameters_list\').show(); 
            $(\'parameters_for_site\').hide();
            $("m_inherit").disable = false;
        } else {
            $(\'parameters_list\').hide(); 
            $(\'parameters_for_site\').show();
            $(\'m_inherit\').checked = false;
            $("m_inherit").disable = true;
        }    
    });
</script>
'; ?>
